﻿@{
    ViewBag.Title = "调查";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model ElingOA6_DSJCJ.Model.Paper
@{
    ElingOA6_DSJCJ.BLL.PaperAnswerOption paperAnswerOptionBLL = new ElingOA6_DSJCJ.BLL.PaperAnswerOption();
    decimal paperId = Model.FPaperId;

    List<ElingOA6_DSJCJ.Model.PaperTopic> paperTopicList = ViewData["paperTopicList"] == null ?
        new List<ElingOA6_DSJCJ.Model.PaperTopic>() : ViewData["paperTopicList"] as List<ElingOA6_DSJCJ.Model.PaperTopic>;
    int topicCount = paperTopicList.Count;

    //string chartData = ViewData["chartData"] == null ? "[]" : ViewData["chartData"].ToString();
    string chartType = ViewData["chartType"] == null ? "1" : ViewData["chartType"].ToString();
}
@if (false)
{
    <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
   
    <script src="../../Scripts/json2.js" type="text/javascript"></script>  
}

<script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/amcharts.js", true)" type="text/javascript"></script>

<script>
    var paperId=@paperId;
    
    var topicCount=@topicCount;
    var chartType=@chartType;
</script>

<script type="text/javascript">
    $(document).ready(function () {

        var chart = new Array(count);
        var legend;
        if (chartType == 1) {

            var chartData = JSON.parse($("#hidchartData").val());
            var count = chartData.length;
            AmCharts.ready(function () {
                for (var i = 0; i < count; i++) {
                    // PIE CHART
                    chart[i] = new AmCharts.AmPieChart();
                    chart[i].dataProvider = chartData[i];
                    chart[i].titleField = "country";
                    chart[i].valueField = "value";
                    chart[i].outlineColor = "#FFFFFF";
                    chart[i].outlineAlpha = 0.8;
                    chart[i].outlineThickness = 5;
                    // this makes the chart 3D
                    chart[i].depth3D = 15;
                    chart[i].angle = 30;
                    chart[i].clickSlice = function (a) {
                        if (a.dataContext.aw == "Y") {
                            window.location.href = '/Paper/PaperAnswerList?autoID=' + a.dataContext.id + '&paperType=1';
                        }
                    }

                    // WRITE
                    chart[i].write("chartdiv" + i + "");
                }

            });
        }
        else {
            var chartData = JSON.parse($("#hidchartData").val());
            var count = chartData.length;
            AmCharts.ready(function () {
                for (var i = 0; i < count; i++) {
                    // SERIAL CHART
                    chart[i] = new AmCharts.AmSerialChart();
                    chart[i].dataProvider = chartData[i];
                    chart[i].categoryField = "country";
                    // the following two lines makes chart 3D
                    chart[i].depth3D = 20;
                    chart[i].angle = 30;

                    // AXES
                    // category
                    var categoryAxis = chart[i].categoryAxis;
                    categoryAxis.labelRotation = 90;
                    categoryAxis.dashLength = 5;
                    categoryAxis.gridPosition = "start";

                    // value
                    var valueAxis = new AmCharts.ValueAxis();
                    valueAxis.title = "Visitors";
                    valueAxis.dashLength = 5;
                    chart[i].addValueAxis(valueAxis);

                    // GRAPH            
                    var graph = new AmCharts.AmGraph();
                    graph.valueField = "visits";
                    graph.colorField = "color";
                    graph.balloonText = "[[category]]: [[value]]";
                    graph.type = "column";
                    graph.lineAlpha = 0;
                    graph.fillAlphas = 1;
                    graph.handleClick = function (a) {
                        if (a.dataContext.aw == "Y") {
                            window.location.href = '/Paper/PaperAnswerList?autoID=' + a.dataContext.id + '&paperType=1';
                        }
                    };
                    chart[i].addGraph(graph);

                    // WRITE
                    chart[i].write("chartdiv" + i + "");

                }
            });
        }
    });
        
</script>

<style>
    .top-bg
    {
        background: #f5f5f5;
        border-bottom: #aaaaaa 2px solid;
    }
    .titname
    {
        color: #1555a9;
        font-size: 20px;
        font-weight: 700;
        padding-bottom: 4px;
    }
    .titintro
    {
        color: #3c3c3d;
        padding-bottom: 10px;
    }
    .content
    {
        margin: 0px auto;
        width: 900px;
        position: relative;
        
        
    }
    .next
    {
       
        text-align: center;
        position: relative;
        height: 40px;
    }
    .nextbnt
    {
        background: url(@Url.Content("~/Content/images/bntbg.gif")) no-repeat;
        width: 122px;
        height: 36px;
        line-height: 36px;
        display: inline-block;
        text-align: center;
        font-size: 14px;
        font-family: "幼圆";
        color: #fff;
        cursor: pointer;
        border: 0;
        margin: 0 10px;
    }
    .nextbnt a
    {
        color: #fff;
        text-decoration: none;
    }
    
</style>
<table width="1000" align="center" cellspacing="0" style="margin-top: 0px;">
    <tr>
        <td align="center" bgcolor="#FFFFFF">
            <table width="980" align="center" cellspacing="0" style="margin-top: 0px;">
                <tr>
                    <td width="36">
                        <img src="@Url.Content("~/Content/images/icon2.jpg", true)" width="36" height="31" />
                    </td>
                    <td width="100%" align="left" class="title" style="background: url(@Url.Content("~/Content/images/titlebg.jpg", true)) repeat-x">
                        问卷调查 <a href="/Paper/PaperAnswer?paperId=@paperId&chartType=1">饼图</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/Paper/PaperAnswer?paperId=@paperId&chartType=2">柱状图</a>
                    </td>
                </tr>
                <tr>
                    <td width="100%" align="left" bgcolor="#FFFFFF" colspan="2">
                        <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
                            <tr>
                                <td colspan="2">
                                    <div class="top-bg fixed">
                                    </div>
                                    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" style="margin-top: 10px;
                                        margin-bottom: 10px;">
                                        <tr>
                                            <td align="center" class="db">
                                                <div class="titname" id="titname">
                                                    @Model.FTitle</div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div class="content" id="titintro" style="margin-top: 5px; margin-buttom: 5px">
                                                    @Model.FContent
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div class="content">
                                                    <table align="left">
                                                        @{int topicSeqId = 1;
                                                          List<ElingOA6_DSJCJ.Model.PaperAnswerOption> paperAnswerOptionList = new List<ElingOA6_DSJCJ.Model.PaperAnswerOption>();
                                                          int i = 0;
                                                          
                                                        }
                                                        @foreach (ElingOA6_DSJCJ.Model.PaperTopic paperTopicModel in paperTopicList)
                                                        {
                                                                
                                                            <tr class="pt2">
                                                                <td>
                                                                    <table align="left">
                                                                        <tr clas>
                                                                            <td align="left" colspan="2" style="font-weight: bold">
                                                                                @topicSeqId、@paperTopicModel.FTopic
                                                                                <input type="hidden"  value="@paperTopicModel.FPaperTopicId" />
                                                                            </td>
                                                                        </tr>
                                                                        @if (paperTopicModel.FTopicType == "A")
                                                                        {
                                                                            paperAnswerOptionList = paperAnswerOptionBLL.GetModelList(paperTopicModel.FPaperTopicId);
                                                                            <tr>
                                                                                <td colspan="2">
                                                                                    简答题内容:</td>
                                                                            </tr>
                                                                            foreach (var p in paperAnswerOptionList)
                                                                            {
                                                                            <tr>
                                                                                <td colspan="2">
                                                                                    &nbsp;@p.FAnswerContent
                                                                                </td>
                                                                            </tr>
                                                                            }
                                                                            topicSeqId++;
                                                                        }
                                                                        else
                                                                        {
                                                                            paperAnswerOptionList = paperAnswerOptionBLL.GetModelList(paperTopicModel.FPaperTopicId);
                                                                            foreach (var p in paperAnswerOptionList)
                                                                            {

                                                                                if (p.FIsRestsAnswer == "Y")
                                                                                {
                                                                            <tr>
                                                                                <td valign='top'>
                                                                                    &nbsp;@p.FAnswerNo .其它</td>
                                                                                <td>
                                                                                </td>
                                                                            </tr>
                                                                                }
                                                                                else
                                                                                {
                                                                            <tr>
                                                                                <td colspan="2">
                                                                                    &nbsp;@p.FAnswerNo .@p.FAnswerContent</td>
                                                                            </tr>
                                                                                }

                                                                            }

                                                                            topicSeqId++;
                                                                            <tr>
                                                                                <td colspan="2">
                                                                                    <table width="420" align="right">
                                                                                        <tr>
                                                                                            <td>
                                                                                                @{string chartId = "chartdiv" + i;}
                                                                                                <div id="@chartId" 
                                                                                style="width: 100%; height: 220px;">
                                                                                                </div>
                                                                                            </td>
                                                                                        </tr>
                                                                                    </table>
                                                                                </td>
                                                                            </tr>
                                                                                                  i++;
                                                                        }
                                                                        <tr>
                                                                            <td colspan="2">
                                                                                &nbsp </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                                       
                                                        }
                                                    </table>
                                                </div>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
@Html.Hidden("hidpaper", "")
@Html.Hidden("hidFPaperId", paperId)
@Html.Hidden("hidFPaperTopicId", topicCount)
@Html.Hidden("hidchartData", ViewData["chartData"] == null ? "[]" : ViewData["chartData"].ToString())
